//
//  MusicView.m
//  TTDT_1
//
//  Created by lanou on 15/9/8.
//  Copyright (c) 2015年 zhengyl. All rights reserved.
//

#import "MusicView.h"
#import "Define.h"
#import "SubView.h"


#define kLineSpace 15

@interface MusicView ()

@property (nonatomic, strong) UIView *bgView;//主View,子视图添加在这个视图上

@property (nonatomic, strong) SubView *songNewSubView;//新歌首发
@property (nonatomic, strong) SubView *sortSubView;//排行
@property (nonatomic, strong) SubView *singerSubView;//歌手
@property (nonatomic, strong) SubView *categorySubView;//分类
@property (nonatomic, strong) SubView *everyOneSubView;//大家在听

@end


@implementation MusicView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.contentSize = CGSizeMake(0, self.bounds.size.height + 0.5);//给0.5偏移量,可以有拉动效果
        //添加一个主View
        self.bgView = [[UIScrollView alloc] initWithFrame:self.bounds];
        self.bgView.backgroundColor = [UIColor whiteColor];
        [self addSubview:self.bgView];
        
        //宽度
        CGFloat width = (([UIScreen mainScreen].bounds.size.width - kLineSpace * 3) / 2);
        CGFloat height = ((kScreenHeight - kTitleHeight - kMusicHeight) - kLineSpace * 4) / 3;
        //1,新歌首发
        self.songNewSubView = [[SubView alloc] initWithFrame:CGRectMake(kLineSpace, kLineSpace, width, height)];
        [self.songNewSubView setBgImage:[UIImage imageNamed:@"NewSong.jpg"] btnImage:[UIImage imageNamed:@"NewSong01"] label:@"新歌首发"];
        [self.songNewSubView addTarget:self action:@selector(newSong) forControlEvents:UIControlEventTouchUpInside];
        [self.bgView addSubview:self.songNewSubView];
        
        //2,排行
        self.sortSubView = [[SubView alloc] initWithFrame:CGRectMake(kLineSpace * 2 + width, kLineSpace, width, height)];
        [self.sortSubView setBgImage:[UIImage imageNamed:@"Ranklist.jpg"] btnImage:[UIImage imageNamed:@"Ranklist01"] label:@"排行"];
        [self.sortSubView addTarget:self action:@selector(sort) forControlEvents:UIControlEventTouchUpInside];
        [self.bgView addSubview:self.sortSubView];
        
        //3,歌手
        self.singerSubView = [[SubView alloc] initWithFrame:CGRectMake(kLineSpace, kLineSpace * 2 + height, width, height)];
        [self.singerSubView setBgImage:[UIImage imageNamed:@"Singer.jpg"] btnImage:[UIImage imageNamed:@"Singer01"] label:@"歌手"];
        [self.singerSubView addTarget:self action:@selector(singer) forControlEvents:UIControlEventTouchUpInside];
        [self.bgView addSubview:self.singerSubView];
        
        //4,分类
        self.categorySubView = [[SubView alloc] initWithFrame:CGRectMake(kLineSpace * 2 + width, kLineSpace * 2 + height, width, height)];
        [self.categorySubView setBgImage:[UIImage imageNamed:@"Category.jpg"] btnImage:[UIImage imageNamed:@"Category01"] label:@"分类"];
        [self.categorySubView addTarget:self action:@selector(categoryTo) forControlEvents:UIControlEventTouchUpInside];
        [self.bgView addSubview:self.categorySubView];
        
        //5,大家在听
        self.everyOneSubView = [[SubView alloc] initWithFrame:CGRectMake(kLineSpace, kLineSpace * 3 + height * 2, width, height)];
        [self.everyOneSubView setBgImage:[UIImage imageNamed:@"EveryOne.jpg"] btnImage:[UIImage imageNamed:@"EveryOne01"] label:@"大家在听"];
        [self.everyOneSubView addTarget:self action:@selector(everyOne) forControlEvents:UIControlEventTouchUpInside];
        [self.bgView addSubview:self.everyOneSubView];
        
    }
    return self;
}

//1,新歌
- (void)newSong {
    NSLog(@"新歌首发");
}
//2,排行
- (void)sort {
    NSLog(@"排行");
}
//3,歌手
- (void)singer {
    NSLog(@"歌手");
}
//4,分类
- (void)categoryTo {
    NSLog(@"分类");
}
//5,大家在听
- (void)everyOne {
    NSLog(@"大家在听");
}




@end
